<?php
$goods = mysqli_connect("localhost","root","root","goods");
$type = $_GET["id"];
$goodinfo;
if($type == -1){
    $goodinfo = mysqli_query($goods,"select * from goodsinfo");
}else{
    $goodinfo = mysqli_query($goods,"select * from goodsinfo where type = {$type}");
}


$arr = [];
while($res=mysqli_fetch_assoc($goodinfo)){
    $arr[] = $res;
}
echo json_encode($arr);


?>